package HashSet集合;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author Administrator
 * @ClassName HashSetTest
 * @TIME 星期二 2020/12/29
 */
public class HashSetTest {
    public static void main(String[] args) {
        Set<Person> sp = new HashSet<>();
        Set<Person> sp2 = new HashSet<>();
        Set<Person> sp3 = new HashSet<>();

        sp.add(new Person("小黑", 15));
        sp.add(new Person("小黑", 15));
        sp.add(new Person("小琼", 20));
        Iterator iterator = sp.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        System.out.println(sp.equals(sp));
        System.out.println(sp.hashCode());
        System.out.println(sp.hashCode());


        Object[] objArr = sp.toArray();
        for (Object obj : objArr) {
            System.out.println(obj);
        }

    }
}
